package com.turing.usdtpay.utils;

import android.content.Context;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import com.turing.usdtpay.R;

/**
 * @作者：JAY
 * @创建时间：2019/10/21 16:16
 * @描述：
 **/
public class ToastUtils {

    public static void showToast(Context context, String msg) {
        if (context == null){
            context = Utils.getContext();
            if (context == null){
                return;
            }
        }
        Toast toast = new Toast(context);
        //设置Toast显示位置，居中，向 X、Y轴偏移量均为0
        toast.setGravity(Gravity.CENTER, 0, 0);
        //获取自定义视图
        View view = LayoutInflater.from(context).inflate(R.layout.totast, null);
        TextView tvMessage = (TextView) view.findViewById(R.id.tv_toast);
        //设置文本
        tvMessage.setText(msg);
        //设置视图
        toast.setView(view);
        //设置显示时长
        toast.setDuration(Toast.LENGTH_SHORT);
        //显示
        toast.show();
    }

    public static void showNormolToast(Context context, String msg){
        if (context == null){
            context = Utils.getContext();
            if (context == null){
                return;
            }
        }
        Toast toast = new Toast(context);
        View view = LayoutInflater.from(context).inflate(R.layout.totast, null);
        TextView tvMessage = (TextView) view.findViewById(R.id.tv_toast);
        //设置文本
        tvMessage.setText(msg);
        //设置视图
        toast.setView(view);
        //设置显示时长
        toast.setDuration(Toast.LENGTH_SHORT);
        //显示
        toast.show();
    }
}
